package com.againstsky.algorithm.sort;

import com.againstsky.algorithm.bean.SortBase;

/**
 * Created by agasinst on 2017/9/25.
 * 自顶向下排序算法
 */
public class TopDownMergeSort extends MergeSortBase {

//    private Comparable[] aux;

    @Override
    public void sort(Comparable[] a) {
        aux=new Comparable[a.length];
        sort(a,0,a.length-1);
    }

    public void sort(Comparable[] a,int lo,int hi){
        if(hi<=lo) return;
        int mid=lo+(hi-lo)/2;
        sort(a,lo,mid);
        sort(a,mid+1,hi);
        merge(a,lo,mid,hi);
    }


}
